package com.demo2do.fms.entity.vehicle.source;

import java.beans.Transient;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;

/**
 * 
 * @author mohanlan
 *
 */
@Entity
@Table(name = "REMOTE_TRANS_MEANS")
@DynamicUpdate
public class RemoteTransMeans {
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "generator")
    @SequenceGenerator(name = "generator", sequenceName = "HIBERNATE_SEQUENCE", allocationSize = 1)
    private Long id;
    
    private String code;
    
    private String name;
    
    @Column(name = "BARCODE")
    private String barCode;
    
    private Long engineTypeId;
    
    private Long loadTypeId;
    
    private Long cityId;
    
    private Long ownerId;
    
    private Long balancerId;
    
    private Integer startYear;
    
    private Integer depreciationYear;
    
    private Integer examMonth;
    
    @Column(name = "IS_DISABLED")
    private Boolean disabled;
    
    private Date createdTime;
    
    private Date lastModified;
    
    private Long lastOperator;
    
    private Long truckTeamId;
    
    @Column(name = "IS_OPTIMIZED")
    private Boolean optimized;
    
    private Long tmLoadTypeId;
    
    @Column(name = "IS_AUTO")
    private Boolean auto;
    
    private Long intelOperatorId;
    
    @Column(name = "IS_LOCKED")
    private Boolean locked;
    
    private String driverName;
    
    private String driverTel;
    
    private String nameDesc;
    
    private String rfid;
    
    @Column(name = "IS_VIRTUAL")
    private Boolean virtual;
    
    private String rfidValid;
    
    private Long createdOperator;
    
    @Column(name = "is_temporary_increase")
    private Boolean temporaryIncrease;
    
    private Long temporaryIncreaseDate;
    
    private Date temporaryIncreaseLockdate;
    
    private String country;
    
    private Date unlockDate;
    
    private String lockType;
    
    private String mark;
    
    @Column(name = "is_special_trans")
    private Integer specialTrans;
    
    private String gpsDeviceNumber;
    
    @Column(name = "is_send")
    private Boolean send;
    
    private String specialCapac;
    
    private Long lockUnlockOperator;
    
    private Date lastLoadTime;
    
    private Long transCarrier;
    
    /**
     * The default constructor
     */
    public RemoteTransMeans() {
    }
    
    /**
     * @param gpsDeviceNumber
     * @param lastModified
     * @return
     */
    public RemoteTransMeans editGps(String gpsDeviceNumber, Date lastModified) {
        this.gpsDeviceNumber = gpsDeviceNumber;
        this.lastModified = lastModified;
        return this;
    }
    
    /**
     * 
     * @return
     */
    @Transient
    public boolean isAvaliable() {
    	
    	if (this.specialTrans == null) {
    		return false;
    	}
    	
        return (this.specialTrans.intValue() == 0) || (this.specialTrans.intValue() == 2);
        
    }
    
    /**
     * @return
     */
    public boolean isLock() {
        return this.locked;
    }
    
    /**
     * @param type
     * @param operator
     * @return
     */
    public RemoteTransMeans lock(LockType type, Long operator) {
        this.locked = true;
        this.lockType = type.getCode();
        this.lockUnlockOperator = operator;
        this.unlockDate = new Date();
        this.lastOperator = operator;
        this.lastModified = new Date();
        return this;
    }
    
    /**
     * @param operator
     * @return
     */
    public RemoteTransMeans unlock(Long operator) {
        this.locked = false;
        this.lockType = null;
        this.lockUnlockOperator = operator;
        this.unlockDate = new Date();
        this.lastOperator = operator;
        this.lastModified = new Date();
        return this;
    }

    /**
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * @return the code
     */
    public String getCode() {
        return code;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @return the barCode
     */
    public String getBarCode() {
        return barCode;
    }

    /**
     * @return the engineTypeId
     */
    public Long getEngineTypeId() {
        return engineTypeId;
    }

    /**
     * @return the loadTypeId
     */
    public Long getLoadTypeId() {
        return loadTypeId;
    }

    /**
     * @return the cityId
     */
    public Long getCityId() {
        return cityId;
    }

    /**
     * @return the ownerId
     */
    public Long getOwnerId() {
        return ownerId;
    }

    /**
     * @return the balancerId
     */
    public Long getBalancerId() {
        return balancerId;
    }

    /**
     * @return the startYear
     */
    public Integer getStartYear() {
        return startYear;
    }

    /**
     * @return the depreciationYear
     */
    public Integer getDepreciationYear() {
        return depreciationYear;
    }

    /**
     * @return the examMonth
     */
    public Integer getExamMonth() {
        return examMonth;
    }

    /**
     * @return the disabled
     */
    public Boolean getDisabled() {
        return disabled;
    }

    /**
     * @return the createdTime
     */
    public Date getCreatedTime() {
        return createdTime;
    }

    /**
     * @return the lastModified
     */
    public Date getLastModified() {
        return lastModified;
    }

    /**
     * @return the lastOperator
     */
    public Long getLastOperator() {
        return lastOperator;
    }

    /**
     * @return the truckTeamId
     */
    public Long getTruckTeamId() {
        return truckTeamId;
    }

    /**
     * @return the optimized
     */
    public Boolean getOptimized() {
        return optimized;
    }

    /**
     * @return the tmLoadTypeId
     */
    public Long getTmLoadTypeId() {
        return tmLoadTypeId;
    }

    /**
     * @return the auto
     */
    public Boolean getAuto() {
        return auto;
    }

    /**
     * @return the intelOperatorId
     */
    public Long getIntelOperatorId() {
        return intelOperatorId;
    }

    /**
     * @return the locked
     */
    public Boolean getLocked() {
        return locked;
    }

    /**
     * @return the driverName
     */
    public String getDriverName() {
        return driverName;
    }

    /**
     * @return the driverTel
     */
    public String getDriverTel() {
        return driverTel;
    }

    /**
     * @return the nameDesc
     */
    public String getNameDesc() {
        return nameDesc;
    }

    /**
     * @return the rfid
     */
    public String getRfid() {
        return rfid;
    }

    /**
     * @return the virtual
     */
    public Boolean getVirtual() {
        return virtual;
    }

    /**
     * @return the rfidValid
     */
    public String getRfidValid() {
        return rfidValid;
    }

    /**
     * @return the createdOperator
     */
    public Long getCreatedOperator() {
        return createdOperator;
    }

    /**
     * @return the temporaryIncrease
     */
    public Boolean getTemporaryIncrease() {
        return temporaryIncrease;
    }

    /**
     * @return the temporaryIncreaseDate
     */
    public Long getTemporaryIncreaseDate() {
        return temporaryIncreaseDate;
    }

    /**
     * @return the temporaryIncreaseLockdate
     */
    public Date getTemporaryIncreaseLockdate() {
        return temporaryIncreaseLockdate;
    }

    /**
     * @return the country
     */
    public String getCountry() {
        return country;
    }

    /**
     * @return the unlockDate
     */
    public Date getUnlockDate() {
        return unlockDate;
    }

    /**
     * @return the lockType
     */
    public String getLockType() {
        return lockType;
    }

    /**
     * @return the mark
     */
    public String getMark() {
        return mark;
    }

    /**
     * @return the specialTrans
     */
    public Integer getSpecialTrans() {
        return specialTrans;
    }

    /**
     * @return the gpsDeviceNumber
     */
    public String getGpsDeviceNumber() {
        return gpsDeviceNumber;
    }

    /**
     * @return the send
     */
    public Boolean getSend() {
        return send;
    }

    /**
     * @return the specialCapac
     */
    public String getSpecialCapac() {
        return specialCapac;
    }

    /**
     * @return the lockUnlockOperator
     */
    public Long getLockUnlockOperator() {
        return lockUnlockOperator;
    }

    /**
     * @return the lastLoadTime
     */
    public Date getLastLoadTime() {
        return lastLoadTime;
    }

    /**
     * @return the transCarrier
     */
    public Long getTransCarrier() {
        return transCarrier;
    }

    /**
     * @param id the id to set
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @param code the code to set
     */
    public void setCode(String code) {
        this.code = code;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @param barCode the barCode to set
     */
    public void setBarCode(String barCode) {
        this.barCode = barCode;
    }

    /**
     * @param engineTypeId the engineTypeId to set
     */
    public void setEngineTypeId(Long engineTypeId) {
        this.engineTypeId = engineTypeId;
    }

    /**
     * @param loadTypeId the loadTypeId to set
     */
    public void setLoadTypeId(Long loadTypeId) {
        this.loadTypeId = loadTypeId;
    }

    /**
     * @param cityId the cityId to set
     */
    public void setCityId(Long cityId) {
        this.cityId = cityId;
    }

    /**
     * @param ownerId the ownerId to set
     */
    public void setOwnerId(Long ownerId) {
        this.ownerId = ownerId;
    }

    /**
     * @param balancerId the balancerId to set
     */
    public void setBalancerId(Long balancerId) {
        this.balancerId = balancerId;
    }

    /**
     * @param startYear the startYear to set
     */
    public void setStartYear(Integer startYear) {
        this.startYear = startYear;
    }

    /**
     * @param depreciationYear the depreciationYear to set
     */
    public void setDepreciationYear(Integer depreciationYear) {
        this.depreciationYear = depreciationYear;
    }

    /**
     * @param examMonth the examMonth to set
     */
    public void setExamMonth(Integer examMonth) {
        this.examMonth = examMonth;
    }

    /**
     * @param disabled the disabled to set
     */
    public void setDisabled(Boolean disabled) {
        this.disabled = disabled;
    }

    /**
     * @param createdTime the createdTime to set
     */
    public void setCreatedTime(Date createdTime) {
        this.createdTime = createdTime;
    }

    /**
     * @param lastModified the lastModified to set
     */
    public void setLastModified(Date lastModified) {
        this.lastModified = lastModified;
    }

    /**
     * @param lastOperator the lastOperator to set
     */
    public void setLastOperator(Long lastOperator) {
        this.lastOperator = lastOperator;
    }

    /**
     * @param truckTeamId the truckTeamId to set
     */
    public void setTruckTeamId(Long truckTeamId) {
        this.truckTeamId = truckTeamId;
    }

    /**
     * @param optimized the optimized to set
     */
    public void setOptimized(Boolean optimized) {
        this.optimized = optimized;
    }

    /**
     * @param tmLoadTypeId the tmLoadTypeId to set
     */
    public void setTmLoadTypeId(Long tmLoadTypeId) {
        this.tmLoadTypeId = tmLoadTypeId;
    }

    /**
     * @param auto the auto to set
     */
    public void setAuto(Boolean auto) {
        this.auto = auto;
    }

    /**
     * @param intelOperatorId the intelOperatorId to set
     */
    public void setIntelOperatorId(Long intelOperatorId) {
        this.intelOperatorId = intelOperatorId;
    }

    /**
     * @param locked the locked to set
     */
    public void setLocked(Boolean locked) {
        this.locked = locked;
    }

    /**
     * @param driverName the driverName to set
     */
    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    /**
     * @param driverTel the driverTel to set
     */
    public void setDriverTel(String driverTel) {
        this.driverTel = driverTel;
    }

    /**
     * @param nameDesc the nameDesc to set
     */
    public void setNameDesc(String nameDesc) {
        this.nameDesc = nameDesc;
    }

    /**
     * @param rfid the rfid to set
     */
    public void setRfid(String rfid) {
        this.rfid = rfid;
    }

    /**
     * @param virtual the virtual to set
     */
    public void setVirtual(Boolean virtual) {
        this.virtual = virtual;
    }

    /**
     * @param rfidValid the rfidValid to set
     */
    public void setRfidValid(String rfidValid) {
        this.rfidValid = rfidValid;
    }

    /**
     * @param createdOperator the createdOperator to set
     */
    public void setCreatedOperator(Long createdOperator) {
        this.createdOperator = createdOperator;
    }

    /**
     * @param temporaryIncrease the temporaryIncrease to set
     */
    public void setTemporaryIncrease(Boolean temporaryIncrease) {
        this.temporaryIncrease = temporaryIncrease;
    }

    /**
     * @param temporaryIncreaseDate the temporaryIncreaseDate to set
     */
    public void setTemporaryIncreaseDate(Long temporaryIncreaseDate) {
        this.temporaryIncreaseDate = temporaryIncreaseDate;
    }

    /**
     * @param temporaryIncreaseLockdate the temporaryIncreaseLockdate to set
     */
    public void setTemporaryIncreaseLockdate(Date temporaryIncreaseLockdate) {
        this.temporaryIncreaseLockdate = temporaryIncreaseLockdate;
    }

    /**
     * @param country the country to set
     */
    public void setCountry(String country) {
        this.country = country;
    }

    /**
     * @param unlockDate the unlockDate to set
     */
    public void setUnlockDate(Date unlockDate) {
        this.unlockDate = unlockDate;
    }

    /**
     * @param lockType the lockType to set
     */
    public void setLockType(String lockType) {
        this.lockType = lockType;
    }

    /**
     * @param mark the mark to set
     */
    public void setMark(String mark) {
        this.mark = mark;
    }

    /**
     * @param specialTrans the specialTrans to set
     */
    public void setSpecialTrans(Integer specialTrans) {
        this.specialTrans = specialTrans;
    }

    /**
     * @param gpsDeviceNumber the gpsDeviceNumber to set
     */
    public void setGpsDeviceNumber(String gpsDeviceNumber) {
        this.gpsDeviceNumber = gpsDeviceNumber;
    }

    /**
     * @param send the send to set
     */
    public void setSend(Boolean send) {
        this.send = send;
    }

    /**
     * @param specialCapac the specialCapac to set
     */
    public void setSpecialCapac(String specialCapac) {
        this.specialCapac = specialCapac;
    }

    /**
     * @param lockUnlockOperator the lockUnlockOperator to set
     */
    public void setLockUnlockOperator(Long lockUnlockOperator) {
        this.lockUnlockOperator = lockUnlockOperator;
    }

    /**
     * @param lastLoadTime the lastLoadTime to set
     */
    public void setLastLoadTime(Date lastLoadTime) {
        this.lastLoadTime = lastLoadTime;
    }

    /**
     * @param transCarrier the transCarrier to set
     */
    public void setTransCarrier(Long transCarrier) {
        this.transCarrier = transCarrier;
    }

}
